package com.ghh.dao;

import com.ghh.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface OrderSettingDao {

    //判断当前日期是否已经进行了设置
    @Select("select count(1) from t_ordersetting where orderDate = #{orderDate}")
    long findCountByOrderDate(Date orderDate);

    //修改预约设置
    @Update("update t_ordersetting set number = #{number} where orderDate = #{orderDate}")
    void editNumberByOrderDate(OrderSetting orderSetting);

    //添加预约设置
    @Insert("insert into t_ordersetting values (null,#{orderDate},#{number},#{reservations})")
    void add(OrderSetting orderSetting);

    //查询某年某月的预约设置
    @Select("select  day(orderDate) date,number,reservations FROM t_ordersetting where concat(year(orderDate),'-',month(orderDate)) = #{date}")
    List<Map<String, Object>> getOrderSettingByMonth(String date);

    //根据日期查询预约设置
    @Select("select * from t_ordersetting where orderDate=#{orderDate}")
    OrderSetting findByOrderDate(Date parseString2Date);

    //根据预约日期修改已预约的人数
    @Update("update t_ordersetting set reservations=#{reservations} where orderDate=#{orderDate}")
    void editReservationsByOrderDate(OrderSetting orderSetting);
}
